﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;

namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class NhaCungCapBlo
    {
        #region "Khai báo các biến"
        private NhaCungCapDAO da;
        private NhaCungCapDTO _nhaCC;
        private string _error;
        #endregion

        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public NhaCungCapDTO NhaCC
        {
            get { return _nhaCC; }
            set { _nhaCC = value; }
        }
        #endregion

        #region "Khai báo các Method"
        public NhaCungCapBlo()
        {            
            da = new NhaCungCapDAO();
        }
        public bool InsertNCC(string MaNCC,string TenNCC,string DiaChiNCC,string SDT,string Email,double CongNo)
        {
            _nhaCC = new NhaCungCapDTO(MaNCC, TenNCC, DiaChiNCC, SDT, Email, CongNo);
            if (!da.InsertNCC(NhaCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateNCC(string MaNCC, string TenNCC, string DiaChiNCC, string SDT, string Email, double CongNo)
        {
            _nhaCC = new NhaCungCapDTO(MaNCC, TenNCC, DiaChiNCC, SDT, Email, CongNo);
            if (!da.UpdateNCC(NhaCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteNCC(string MaNCC)
        {
            if (!da.DeleteNCC(MaNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_NhaCungCap()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_NhaCungCap();
            return ds;
        }       
        #endregion                    
    }
}